<template>
  <div class="abnormal">
    <!-- <div class="abnormal-dialog-header">
      <span>查看日志</span>
    </div>-->
    <div class="abnormal-handle-box">
      <el-table :data="tableData" stripe style="width: 100%" v-loading="loading" border>
        <template v-for="(item,index) in logData">
          <el-table-column
            :key="index"
            :prop="item.value"
            :label="item.label"
            v-if="item.value!='insertdate'"
            align="center"
          ></el-table-column>
          <el-table-column
            :key="item.value"
            v-if="item.value=='insertdate'"
            :prop="item.value"
            :label="item.label"
            width="150px"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{scope.row.insertdate}}</span>
            </template>>
          </el-table-column>
        </template>
      </el-table>
    </div>
    <div class="pageBox">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="pageChange"
        :current-page="form.pagenum"
        :page-sizes="[10,20, 30, 50,100]"
        :page-size="form.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="form.total"
        background
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      logData: [
        { label: "招聘企业", value: "companyname" },
        { label: "职位名称", value: "positionname" },
        { label: "工作地点", value: "address" },
        { label: "薪资待遇", value: "offer" },
        { label: "要求年限", value: "worklife" },
        { label: "招聘人数", value: "recruitment" },
        { label: "发布日期", value: "insertdate" },
        { label: "下架类型", value: "soldouttype" },//下架类型
        { label: "下架时间", value: "soldoutdate" } //下架时间
      ],
      tableData: [],
      loading: true,
      form: {
        tabstype: "4",
        companyname: '',
        pagenum: 1,
        pagesize: 10,
        total: 0
      }
    }
  },

  created () {
    this.getData();
  },
  props: ['companyName'],
  methods: {
    getData () {
      this.form.companyname = this.companyName;
      this.$flexibleAxios.post('/app/v1/platform/company/positionlist',
        this.form
      ).then(resp => {
        if (resp.data.message === 'success.') {
          let temp = resp.data.data.list || [];
          if (temp.length > 0) {
            temp.forEach(el => {
              // el.insertdate = el.insertdate.split(" ")[0];
              if (!el.miniwage && el.maxwage) {
                el.offer = `${parseInt(el.maxwage) / 1000}K以下`;
              } else if (!el.maxwage && el.miniwage) {
                el.offer = `${parseInt(el.miniwage) / 1000}K以上`;
              } else if (el.maxwage == el.miniwage) {
                el.offer = `${parseInt(el.miniwage) / 1}元/小时`
              } else {
                el.offer = `${parseInt(el.miniwage) / 1000}-${parseInt(
                  el.maxwage
                ) / 1000}K`;
              }
            });
            temp.forEach(el => {
              // el.insertdate = el.insertdate.split(" ")[0];
              if (el.soldouttype == '0') {
                el.soldouttype = '企业下架'
              } else if (el.soldouttype == '2') {
                el.soldouttype = '平台下架'
              } else {
                el.soldouttype = '全部'
              }
            });
          }

          this.tableData = temp || [];
          this.form.total = Number(resp.data.data.totalnum);
          this.loading = false;

        }
      })
    },
    pageChange (p) {

      // this.form.pagenum = p + "";
      this.form.pagenum = p;
      this.getData();
    },
    handleSizeChange (val) {
      this.form.pagesize = val;
      this.getData();
    },
  },
}
</script>
<style>
.abnormal {
  padding: 10px 15px;
}

.abnormal-dialog-header {
  font-size: 16px;
  box-sizing: border-box;
  padding: 20px;
  border-bottom: 1px solid #e4e4e4;
}

.abnormal-dialog-header::before {
  content: "";
  border-left: 10px solid #0064e4;
  margin-right: 10px;
}

.abnormal-detail-box {
  box-sizing: border-box;
  padding: 20px;
  overflow: auto;
  border-bottom: 1px dashed #e4e4e4;
}
.pageBox {
  margin-top: 10px;
}
</style>


